<?php

namespace App\Admin\Controllers\Service;

use App\Models\ServiceSnapshot;
use Encore\Admin\Controllers\AdminController;
use Encore\Admin\Form;
use Encore\Admin\Grid;
use Encore\Admin\Show;

class SnapshotController extends AdminController
{
    /**
     * Title for current resource.
     *
     * @var string
     */
    protected $title = '快照信息';

    /**
     * Make a grid builder.
     *
     * @return Grid
     */
    protected function grid()
    {
        $grid = new Grid(new ServiceSnapshot());

        $grid->column('id', ___('table.zy_service_snapshot.Id'));
        $grid->column('user_nickname', ___('table.zy_service_snapshot.User nickname'));
        $grid->column('user_icon', ___('table.zy_service_snapshot.User icon'));
        $grid->column('user_phone', ___('table.zy_service_snapshot.User phone'));
        $grid->column('user_province', ___('table.zy_service_snapshot.User province'));
        $grid->column('user_city', ___('table.zy_service_snapshot.User city'));
        $grid->column('user_district', ___('table.zy_service_snapshot.User district'));
        $grid->column('service_category', ___('table.zy_service_snapshot.Service category'));
        $grid->column('service_name', ___('table.zy_service_snapshot.Service name'));
        $grid->column('service_price', ___('table.zy_service_snapshot.Service price'));
        $grid->column('service_time', ___('table.zy_service_snapshot.Service time'));
        $grid->column('service_remarks', ___('table.zy_service_snapshot.Service remarks'));
        $grid->column('service_media', ___('table.zy_service_snapshot.Service media'));
        $grid->column('create_time', ___('table.zy_service_snapshot.Create time'));
        $grid->column('update_time', ___('table.zy_service_snapshot.Update time'));

        return $grid;
    }

    /**
     * Make a show builder.
     *
     * @param mixed $id
     * @return Show
     */
    protected function detail($id)
    {
        $show = new Show(ServiceSnapshot::findOrFail($id));

        $show->field('id', ___('table.zy_service_snapshot.Id'));
        $show->field('user_nickname', ___('table.zy_service_snapshot.User nickname'));
        $show->field('user_icon', ___('table.zy_service_snapshot.User icon'));
        $show->field('user_phone', ___('table.zy_service_snapshot.User phone'));
        $show->field('user_province', ___('table.zy_service_snapshot.User province'));
        $show->field('user_city', ___('table.zy_service_snapshot.User city'));
        $show->field('user_district', ___('table.zy_service_snapshot.User district'));
        $show->field('service_category', ___('table.zy_service_snapshot.Service category'));
        $show->field('service_name', ___('table.zy_service_snapshot.Service name'));
        $show->field('service_price', ___('table.zy_service_snapshot.Service price'));
        $show->field('service_time', ___('table.zy_service_snapshot.Service time'));
        $show->field('service_remarks', ___('table.zy_service_snapshot.Service remarks'));
        $show->field('service_media', ___('table.zy_service_snapshot.Service media'));
        $show->field('create_time', ___('table.zy_service_snapshot.Create time'));
        $show->field('update_time', ___('table.zy_service_snapshot.Update time'));

        return $show;
    }

    /**
     * Make a form builder.
     *
     * @return Form
     */
    protected function form()
    {
        $form = new Form(new ServiceSnapshot());

        $form->text('user_nickname', ___('table.zy_service_snapshot.User nickname'));
        $form->text('user_icon', ___('table.zy_service_snapshot.User icon'));
        $form->text('user_phone', ___('table.zy_service_snapshot.User phone'));
        $form->text('user_province', ___('table.zy_service_snapshot.User province'));
        $form->text('user_city', ___('table.zy_service_snapshot.User city'));
        $form->text('user_district', ___('table.zy_service_snapshot.User district'));
        $form->text('service_category', ___('table.zy_service_snapshot.Service category'));
        $form->text('service_name', ___('table.zy_service_snapshot.Service name'));
        $form->decimal('service_price', ___('table.zy_service_snapshot.Service price'));
        $form->number('service_time', ___('table.zy_service_snapshot.Service time'));
        $form->textarea('service_remarks', ___('table.zy_service_snapshot.Service remarks'));
        $form->text('service_media', ___('table.zy_service_snapshot.Service media'));
        $form->number('create_time', ___('table.zy_service_snapshot.Create time'));
        $form->number('update_time', ___('table.zy_service_snapshot.Update time'));

        return $form;
    }
}
